import request from '@/utils/request';
import type { Customer, NormalListParam, ProductType,SaleTeam,Dealer } from '../../model';

export async function queryProduct(params: NormalListParam) {
  params.pageSize=1000;
  var data =  request('/xwyl/product/productData', {
    params,
  });
  return data;
}

export async function productList(params: NormalListParam) {
  var data =  request('/xwyl/product/productData', {
    params,
  });
  return data;
}

export async function updateStatus(params: any) {
  var data =  request('/xwyl/dealer/updateStatus', {
    params,
  });
  return data;
}


export function insertProduct(params:ProductType){
  return request('/xwyl/product/saveProduct', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}

export function myAccount(params:any){
  return request('/xwyl/putOut/bindCustomer', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}


export function updateProduct(params:ProductType){
  return request('/xwyl/product/updateProduct', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}

export function deleteProduct(params:any){
  return request('/xwyl/product/deleteProduct', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}

export function exportProduct(params:any){
  return request('/xwyl/product/exportProduct', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}

export function importProduct(params:any){
  return request('/xwyl/product/importProduct', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}

export async function querySalesTeam(params: NormalListParam) {
  var data =  request('/xwyl/salesTeam/salesTeamData', {
    params,
  });
  return data;
}

export async function salesTeamTree() {
  var data =  request('/xwyl/salesTeam/salesTeamTree',{
  });
  return data;
}

export async function areaTwo() {
  var data =  request('/xwyl/cm/region/getChinaData',{
  });
  return data;
}

export function saveSalesTeam(params:SaleTeam){
  return request('/xwyl/salesTeam/saveSalesTeam', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}

export function updateSalesTeam(params:SaleTeam){
  return request('/xwyl/salesTeam/updateSalesTeam', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}

export async function hospitalData(params: NormalListParam) {
  var data =  request('/xwyl/hospital/hospitalData', {
    params,
  });
  return data;
}

export  function deleteSalesTeam(params:any){
  return request('/xwyl/salesTeam/deleteSalesTeam', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}


export function saveHospital(params:Customer){
  return request('/xwyl/hospital/saveHospital', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}

export function updateHospital(params:Customer){
  return request('/xwyl/hospital/updateHospital', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}

export  function deleteHospital(params:any){
  return request('/xwyl/hospital/deleteHospital', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}

export async function dealerListData(params: NormalListParam) {
  var data =  request('/xwyl/dealer/dealerListData', {
    params,
  });
  return data;
}

export function saveDealer(params:Dealer){
  return request('/xwyl/dealer/saveDealer', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}

export function updateDealer(params:Dealer){
  return request('/xwyl/dealer/updateDealer', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}


//赠品列表
export async function giftListData(params: NormalListParam) {
  var data =  request('/xwyl/dealerGift/getList', {
    params,
  });
  return data;
}

export function saveGift(params:any){
  return request('/xwyl/dealerGift/add', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}

//赠品列表
export async function dealerDataById(params:any) {
  var data =  request('/xwyl/dealer/dealerDataById', {params});
  return data;
}

//通知公告列表
export async function annListData(params: any) {
  var data =  request('/xwyl/ann/annListData', {
    params,
  });
  return data;
}

export async function annListDataFile(params: any) {
  params.annType=2;
  var data =  request('/xwyl/ann/annListData', {
    params,
  });
  return data;
}

//客户列表
export  function customerList(params: NormalListParam) {
  var data =  request('/xwyl/customer/list', {
    params,
    method:'post'
  });
  return data;
}

export function saveCustomer(params:any){
  return request('/xwyl/customer/insert', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}

export function updateCustomer(params:any){
  return request('/xwyl/customer/update', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}

export  function deleteCustomer(params:any){
  return request('/xwyl/customer/delete', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}

export  function deleteDealer(params:any){
  return request('/xwyl/dealer/deleteDealer', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}

// export  function exportDealer(params:any){
//   return request('/xwyl/dealer/exportDealer', {
//     method: 'post',
//     requestType:'form',
//     data: {
//       ...params,
//     },
//   });
// }

export  function exportDealer(params:any){
  return request('/xwyl/dealer/exportDealerNew', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
    },
  });
}

export  function submitAduit(){
  return request('/xwyl/dealer/submitAduit', {
    method: 'post',
  });
}


export async function aduitStatus(params:any) {
  return request('/xwyl/dealer/aduitStatus', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
      method: 'post',
    },
  });
}

export  function exportHospital(){
  return request('/xwyl/hospital/exportHospital', {
    method: 'post',
  });
}

export  function hospitalDataById(params:any){
  return request('/xwyl/hospital/hospitalDataById', {
    params,
    method: 'post',
  });
}

export  function salesCustomerData(params: any) {
  var data =  request('/xwyl/salesTeam/salesCustomerData', {
    params,
    method:'post'
  });
  return data;
}

export function saveCustomerData(params:any){
  return request('/xwyl/salesTeam/saveCustomerData', {
    method: 'post',
    headers:{
      'Content-Type': 'application/json',
      'authorization':`${sessionStorage.getItem('token')}`
    },
    data: {
      ...params,
      method: 'post',
    },
  });
}

export function addHospitalDetails(params:any){
  return request('/xwyl/hospital/addHospitalDetails', {
    method: 'post',
    headers:{
      'Content-Type': 'application/json',
      'authorization':`${sessionStorage.getItem('token')}`
    },
    data: {
      ...params,
      method: 'post',
    },
  });
}

export function insertSalesTeamArea(params:any){
  return request('/xwyl/salesTeam/insertSalesTeamArea', {
    method: 'post',
    headers:{
      'Content-Type': 'application/json',
      'authorization':`${sessionStorage.getItem('token')}`
    },
    data: {
      ...params,
      method: 'post',
    },
  });
}

export  function findSalesAreaBySalesId(params: any) {
  var data =  request('/xwyl/salesTeam/findSalesAreaBySalesId', {
    params,
    method:'post'
  });
  return data;
}

export  function deletSalesAreaById(params: any) {
  var data =  request('/xwyl/salesTeam/deletSalesAreaById', {
    params,
    method:'post'
  });
  return data;
}

export  function exportSalesTeam(params: any) {
  var data =  request('/xwyl/salesTeam/exportSalesTeam', {
    params,
    method:'post'
  });
  return data;
}

export function signSubmit(params:any){
  return request('/xwyl/sign/signSubmit', {
    method: 'post',
    headers:{
      'Content-Type': 'application/json',
      'authorization':`${sessionStorage.getItem('token')}`
    },
    data: params,
  });
}

export  function signingView(params: any) {
  var data =  request('/xwyl/sign/signingView', {
    params,
    method:'post'
  });
  return data;
}

export  function discountList(params:any){
  return request('/xwyl/discountRule/getList', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
    },
  });
}

export  function addDiscount(params:any){
  return request('/xwyl/discountRule/add', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
    },
  });
}

export  function editDiscount(params:any){
  return request('/xwyl/discountRule/edit', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
    },
  });
}

export  function deleteDiscount(params:any){
  return request('/xwyl/discountRule/delete', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
    },
  });
}


export async function giftNowListData(params: NormalListParam) {
  var data =  request('/xwyl/dealerGift/getList4Now', {
    params,
  });
  return data;
}

export async function giftEdit(params: any) {
  var data =  request('/xwyl/dealerGift/edit', {
    params,
  });
  return data;
}

export async function giftOverdue(params: any) {
  var data =  request('/xwyl/dealerGift/getListOverdue', {
    params,
  });
  return data;
}

export async function expiredDealerList(params: any) {
  var data =  request('/xwyl/dealer/expiredDealerList', {
    params,
  });
  return data;
}

export async function factoryList(params: any) {
  var data =  request('/xwyl/factory/listAllFactory', {
    params,
  });
  return data;
}



export  function saveFactory(params:any){
  return request('/xwyl/factory/saveFactory', {
    method: 'post',
    headers:{
      'Content-Type': 'application/json',
      'authorization':`${sessionStorage.getItem('token')}`
    },
    data: params
  });
}

export  function updateFactory(params:any){
  return request('/xwyl/factory/updateFactory', {
    method: 'post',
    headers:{
      'Content-Type': 'application/json',
      'authorization':`${sessionStorage.getItem('token')}`
    },
    data: params
  });
}


export  function deleteFactory(params:any){
  return request('/xwyl/factory/deleteFactory', {
    params,
  });
}

export async function deptList(params: any) {
  var data =  request('/xwyl/hospitalDepartment/listHospitalDepartment', {
    params,
  });
  return data;
}

export  function savedept(params:any){
  return request('/xwyl/hospitalDepartment/saveHospitalDepartment', {
    method: 'post',
    headers:{
      'Content-Type': 'application/json',
      'authorization':`${sessionStorage.getItem('token')}`
    },
    data: params
  });
}

export  function updatedept(params:any){
  return request('/xwyl/hospitalDepartment/updateHospitalDepartment', {
    method: 'put',
    headers:{
      'Content-Type': 'application/json',
      'authorization':`${sessionStorage.getItem('token')}`
    },
    data: params
  });
}


export  function deletedept(params:any){
  return request('/xwyl/hospitalDepartment/deleteHospitalDepartment', {
    params,
  });
}

export  function saveTeam(params:any){
  return request('/xwyl/team/saveTeam', {
    method: 'post',
    headers:{
      'Content-Type': 'application/json',
      'authorization':`${sessionStorage.getItem('token')}`
    },
    data: params
  });
}

export  function updateTeam(params:any){
  return request('/xwyl/team/updateTeam', {
    method: 'put',
    headers:{
      'Content-Type': 'application/json',
      'authorization':`${sessionStorage.getItem('token')}`
    },
    data: params
  });
}


export  function deleteTeam(params:any){
  return request('/xwyl/team/deleteTeam', {
    params,
  });
}


export async function teamList(params: any) {
  var data =  request('/xwyl/team/listTeam', {
    params,
  });
  return data;
}


export  function saveline(params:any){
  return request('/xwyl/productLine/saveProductLine', {
    method: 'post',
    headers:{
      'Content-Type': 'application/json',
      'authorization':`${sessionStorage.getItem('token')}`
    },
    data: params
  });
}

export  function updateline(params:any){
  return request('/xwyl/productLine/updateProductLine', {
    method: 'put',
    headers:{
      'Content-Type': 'application/json',
      'authorization':`${sessionStorage.getItem('token')}`
    },
    data: params
  });
}


export  function deleteline(params:any){
  return request('/xwyl/productLine/deleteProductLine', {
    params,
  });
}


export async function lineList(params: any) {
  var data =  request('/xwyl/productLine/listProductLine', {
    params,
  });
  return data;
}

export async function getDetailsByTeamId(params:any) {
  var data =  request('/xwyl/team/getDetailsByTeamId', {
    params,
  });
  return data;
}

export  function authTeam(params:any){
  return request('/xwyl/team/addTeamProductLine', {
    method: 'post',
    headers:{
      'Content-Type': 'application/json',
      'authorization':`${sessionStorage.getItem('token')}`
    },
    data: params
  });
}

export  function updateProductShelves(params:any){
  return request('/xwyl/product/updateProductShelves', {
    method: 'post',
    requestType:'form',
    data: {
      ...params,
    },
  });
}
